package com.sgcc.activiti.service.impl;

import com.sgcc.activiti.domain.vo.MonSysDto;
import com.sgcc.activiti.mapper.OMonTarMapper;
import com.sgcc.activiti.service.IOMonTarService;
import com.sgcc.common.core.text.UUID;
import com.sgcc.activiti.domain.OMonTar;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 监控指标Service业务层处理
 *
 * @author sgcc
 * @date 2021-03-22
 */
@Service
public class OMonTarServiceImpl implements IOMonTarService {

    @Autowired
    private OMonTarMapper oMonTarMapper;

    /**
     * 查询监控指标
     *
     * @param id 监控指标ID
     * @return 监控指标
     */
    @Override
    public OMonTar selectOMonTarById(String id) {
        return oMonTarMapper.selectOMonTarById(id);
    }

    /**
     * 查询监控指标列表
     *
     * @param oMonTar 监控指标
     * @return 监控指标
     */
    @Override
    public List<OMonTar> selectOMonTarList(OMonTar oMonTar) {
        return oMonTarMapper.selectOMonTarList(oMonTar);
    }

    /**
     * 新增监控指标
     *
     * @param oMonTar 监控指标
     * @return 结果
     */
    @Override
    public int insertOMonTar(OMonTar oMonTar) {
        if (null == oMonTar.getId()) {
            String id = UUID.randomUUID().toString().replaceAll("-", "");
            oMonTar.setDelFlag("0");
            oMonTar.setId(id);
        }
        return oMonTarMapper.insertOMonTar(oMonTar);
    }

    /**
     * 修改监控指标
     *
     * @param oMonTar 监控指标
     * @return 结果
     */
    @Override
    public int updateOMonTar(OMonTar oMonTar) {
        return oMonTarMapper.updateOMonTar(oMonTar);
    }

    /**
     * 批量删除监控指标
     *
     * @param ids 需要删除的监控指标ID
     * @return 结果
     */
    @Override
    public int deleteOMonTarByIds(String[] ids) {
        return oMonTarMapper.deleteOMonTarByIds(ids);
    }

    /**
     * 删除监控指标信息
     *
     * @param id 监控指标ID
     * @return 结果
     */
    @Override
    public int deleteOMonTarById(String id) {
        return oMonTarMapper.deleteOMonTarById(id);
    }

    @Override
    public OMonTar selectOMonTarByCode(String code) {
        return oMonTarMapper.selectOMonTarByCode(code);
    }

    @Override
    public List<MonSysDto> getMonTarByMonType(String[] monTypes, String[] monSysCodes) {
        List<MonSysDto> monSysList = oMonTarMapper.getMonTarByMonType(monTypes, monSysCodes);
        return  monSysList;
    }
}
